<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        a {
            display: block;
            background-color: pink;
            margin-bottom: 10px;
        }
    </style>
</head>

<body>
    <a href="#">1</a>
    <a href="#">2</a>
    <a href="#">3</a>
    <a href="#">4</a>
    <a href="#">5</a>
    <a href="#">6</a>
    <a href="#">7</a>
    <a href="#">8</a>
    <a href="#">9</a>
    <a href="#">10</a>
    <script>
        let as = document.querySelectorAll('a');
        for (let i = 0; i < as.length; i++) {
            as[i].addEventListener('click', () => {
                console.log(as[i].innerHTML);
            })
        }
    </script>
</body>

</html>